home *** CD-ROM | disk | FTP | other *** search
- Path: vixen.cso.uiuc.edu!usenet
- From: n-dade@uiuc.edu
- Newsgroups: comp.lang.c++
- Subject: Re: works in Borland but not in Microsuck Visual C++
- Date: 15 Mar 1996 01:19:41 GMT
- Organization: University of Illinois at Urbana
- Message-ID: <4iagjd$nli@vixen.cso.uiuc.edu>
- References: <4ia6h8$jes@news.vanderbilt.edu>
- Reply-To: n-dade@uiuc.edu
- NNTP-Posting-Host: homer.apr.uiuc.edu
- X-Newsreader: IBM NewsReader/2 v1.2
-
- In <4ia6h8$jes@news.vanderbilt.edu>, haseltbt@ctrvax.vanderbilt.edu (Bennett Haselton) writes:
- > Dear Abby,
- >
- > The following program was written in completely standard C++
- >and should be portable across platforms. However, it only performs as
- >expected (i.e. sends two copies of 4 to the standard out stream) in Borland
- >C++; when compiled in MicroSUCK Visual C++, it outputs 4 followed by a random
- >integer in the thousands.
-
- Actually it performs as well it is can; the code is wrong.
-
-
- >struct person* matchPerson( struct person* psnPtr )
- >{
- > struct person* ansPtr;
- > ansPtr->age = psnPtr->age;
- > cout << ansPtr->age;
- > cout << ansPtr->age;
- > return ansPtr;
- >};
-
- You use *ansPtr ("ansPtr->age = ...") but ansPtr has not been set to point
- to anything in particular! Where that int goes nobody knows.
-
-
- >i was using version 1.0 of Visual C++; i have no knowledge of whether later
- >Microsuck compilers are capable of handling a program like this properly.
- >Please avoid buying their products whenever possible if you have not already
- >resolved to do so.
-
- Please avoid using uninitialized pointers. :-)
- I do have to agree about MS VC++ in a general sense: there is better out there
- (ie IBM's Visual Age C++ is very sweet IMHO).
-
- -Nicolas Dade / n9rzb / nicolas-dade@uiuc.edu
-
-